DM-54869: Add option to specify alias for the host name in db-auth#142
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for a Cassandra “db-auth alias” that can be used as an additional (higher-priority) hostname when resolving credentials from db-auth.yaml, and exposes this via the apdb-cli create-cassandra command.
Changes:
- Add
dbauth_aliastoApdbCassandraConnectionConfigand thread it throughApdbCassandra.init_database. - Update Cassandra session auth lookup to try the alias first (without a port) before falling back to contact points.
- Add unit tests covering db-auth credential matching behavior (including alias cases) and introduce a small test utility for temporary env var overrides.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_apdbCassandra.py | Adds credential-resolution tests for db-auth matching and new alias behavior. |
| python/lsst/dax/apdb/tests/utils.py | Adds modified_environment context manager used by tests. |
| python/lsst/dax/apdb/cli/options.py | Exposes --dbauth-alias via argparse options derived from Pydantic fields. |
| python/lsst/dax/apdb/cassandra/sessionFactory.py | Tries dbauth_alias first (no port) when resolving DbAuth credentials. |
| python/lsst/dax/apdb/cassandra/config.py | Introduces dbauth_alias config field and its help/description text. |
| python/lsst/dax/apdb/cassandra/apdbCassandra.py | Adds dbauth_alias parameter to init_database and documents it. |
| .pre-commit-config.yaml | Bumps pre-commit hook revisions (pre-commit-hooks and ruff). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #142 +/- ##
==========================================
+ Coverage 84.66% 84.83% +0.16%
==========================================
Files 73 73
Lines 7331 7385 +54
Branches 845 847 +2
==========================================
+ Hits 6207 6265 +58
+ Misses 890 883 -7
- Partials 234 237 +3 ☔ View full report in Codecov by Sentry. |
3b75b61 to
bd08564
Compare
Cassandra connection config class added `dbauth_alias` field which is used
as an additional host name when checking credentials in `db-auth.yaml`.
This alias is checked first, if not found then all contact point hosts
are checked as usual. The alias entry in `db-auth.yaml` does not need
to specify port number, and it looks like (can also include `username@`
as usual):
- url: cassandra://alias_name/
username: ...
password: ...
The `apdb-cli create-cassandra` command adds option `--dbauth-alias` which
defines the alias at database creation time and stores it in the resulting
config file.
7f91c2a to
5d1119c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cassandra connection config class added
dbauth_aliasfield which is usedas an additional host name when checking credentials in
db-auth.yaml.This alias is checked first, if not found then all contact point hosts
are checked as usual. The alias entry in
db-auth.yamldoes not needto specify port number, and it looks like (can also include
username@as usual):
The
apdb-cli create-cassandracommand adds option--dbauth-aliaswhichdefines the alias at database creation time and stores it in the resulting
config file.